export const state = {
  user : sessionStorage.getItem('user') ? JSON.parse(sessionStorage.getItem('user')) : null,
}


export const mutations = {
  changeUser(state,data){
    // 1.将用户信息存入state中
    state.user = data
    // 2.将用户存入sessionStorage
    if(data){
      sessionStorage.setItem("user",JSON.stringify(data))
    }else{
      sessionStorage.removeItem('user');
    }
  }
}
export const getters = {
  user(state){
    return state.user
  }
}
